package com.tbit.api;

import com.tbit.common.entity.pojo.dto.OperatingMapMainDTO;
import com.tbit.common.entity.pojo.vo.OperatingMonitorMainVO;
import com.tbit.manager.api.MachineApi;
import com.tbit.uqbike.object.pojo.dto.OperatingMapMonitoringDTO;
import com.tbit.uqbike.object.pojo.vo.OperatingMonitorV2VO;
import com.tbit.uqbike.service.business.OperatingMapService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 车辆信息远程调用接口
 * @author <a href="mailto:liu.haoxiang@tbit.com.cn">BUGXiang</a>
 * @version 1.0
 * @since 2025-4-24
 */
@Slf4j
@RestController
public class MachineApiImpl implements MachineApi {

    @Resource
    private OperatingMapService operatingMapService;


    /**
     * 运营地图监控接口
     * @param dto OperatingMapMainDTO
     * @return  OperatingMonitorMainVO
     */
    @Override
    public List<OperatingMonitorMainVO> operatingMapMonitoringV2(OperatingMapMainDTO dto) {
        OperatingMapMonitoringDTO operatingMapMonitoringDTO = new OperatingMapMonitoringDTO();
        BeanUtils.copyProperties(dto, operatingMapMonitoringDTO);
        List<OperatingMonitorV2VO> operatingMonitorV2VOS = operatingMapService.operatingMapMonitoringV2(operatingMapMonitoringDTO);
        return operatingMonitorV2VOS.stream().map(this::convertToOperatingMonitorMainVO).collect(Collectors.toList());
    }


    /**
     * 对象转换
     * @param vo    OperatingMonitorV2VO
     * @return      OperatingMonitorMainVO
     */
    private OperatingMonitorMainVO convertToOperatingMonitorMainVO(OperatingMonitorV2VO vo){
        OperatingMonitorMainVO operatingMonitorMainVO = new OperatingMonitorMainVO();
        BeanUtils.copyProperties(vo, operatingMonitorMainVO);
        return operatingMonitorMainVO;
    }
}
